from dtw import dtw ,accelerated_dtw
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import scipy.stats as stats
from matplotlib import rcParams


rcParams['font.sans-serif'] = ['SimHei']  # 中文为宋体
rcParams['font.serif'] = ['Times New Roman']  # 英文为新罗马
rcParams['axes.unicode_minus'] = False  # 正常显示负号
rcParams['font.size'] = 15  # 设置字号

df = pd.read_csv('E:\江苏移动-hzy工作资料\\5GC学习资料\\01-中兴5GC资料\python-tasks\plot-corr\data-test.csv')
df['日期']=pd.to_datetime(df['日期'])
df.set_index(df['日期'],drop=True,inplace=True)
df.drop(columns=['日期'],inplace=True)


d1 = df['蜜汁焗餐包'].interpolate().values
d2 = df['铁板酸菜豆腐'].interpolate().values
d, cost_matrix, acc_cost_matrix, path = accelerated_dtw(d1 ,d2, dist='euclidean')

# 绘制灰度图像,
# interpolation：插值方法。用于控制图像的平滑程度和细节程度。可以选择nearest、bilinear、bicubic等插值方法。
plt.imshow(acc_cost_matrix.T, origin='lower', cmap='gray', interpolation='nearest')

plt.plot(path[0], path[1], 'w')
plt.xlabel('Subject1')
plt.ylabel('Subject2')
plt.title(f'DTW Minimum Path with minimum distance: {np.round(d ,2)}')
plt.show()